package com.medi.chats.controller;

import com.medi.chats.listener.events.CheckEvent;
import com.medi.chats.utils.ContextUtil;
import com.medi.chats.utils.MyConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HelloController {
    @Autowired
    MyConfig myConfig;

    @ResponseBody
    @RequestMapping("/hello")
    public String hello() {
        return "Hello Wod";
    }

    @RequestMapping("/")
    public String index(ModelMap map) {
        ContextUtil.getApplicationContext().publishEvent(new CheckEvent("sssssssssss")); //放不为空数据,或者要处理的数据

        map.addAttribute("host", myConfig.getUploadPath());
        return "index";
    }

}
